VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsNavigation"
Attribute VB_GlobalNameSpace = True
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Public Sub ApplyFrameTheme(tmpFrame As Object, tmpForm As Object)
    Dim tmpObj As Object
    For Each tmpObj In tmpForm
        If (TypeName(tmpObj) = "oTextBox") Then
            tmpObj.LabelBackColor = tmpFrame.FillColor
        End If
    Next
End Sub

Public Sub LoadComboTypes(tmpForm As Object, tmpCbo As Object)
    On Error GoTo ErrHandler
    Dim i As Integer
    Dim a As New clsDatabaseModules
    Dim cboType() As String
    cboType = Split(a.GetValFrTable("cValue", "System_Settings", "cCode='" & Mid$(tmpForm.Name, 4, Len(tmpForm.Name)) & "' and cType = 'TYPES'"), ",")
    tmpCbo.Clear
    For i = 0 To UBound(cboType)
        tmpCbo.AddItem cboType(i)
    Next i
    tmpCbo.Text = cboType(0)
ErrHandler:
End Sub

Public Sub ControlObjects(tmpForm As Object)
    Dim tmpObj As Object
    Dim tmpTag As Object
    Select Case tmpForm.Mode
        Case AddEditNew
            For Each tmpObj In tmpForm
                If (TypeName(tmpObj) = "oTextBox" And tmpObj.Tag <> ".") Then
                    tmpObj.Enabled = True
                    If tmpObj.Tag = "1" Then
                        Set tmpTag = tmpObj
                    End If
                ElseIf (TypeName(tmpObj) = "oDateBox") Then
                    tmpObj.Enabled = True
                ElseIf (TypeName(tmpObj) = "DataGrid") Then
                    If tmpObj.Tag <> "." Then
                        tmpObj.Enabled = True
                    End If
                ElseIf (TypeName(tmpObj) = "ComboBox") Then
                    tmpObj.Enabled = True
                ElseIf (TypeName(tmpObj) = "oTab") Then
                    tmpObj.ActiveTab = 0
                    tmpObj.TabEnabled(1) = False
                End If
            Next
            If Not (tmpTag Is Nothing) Then tmpTag.SetFocus
        Case Find, Normal
            For Each tmpObj In tmpForm
                If (TypeName(tmpObj) = "oTextBox" And tmpObj.Tag <> ".") Then
                    tmpObj.Enabled = False
                ElseIf (TypeName(tmpObj) = "oDateBox") Then
                    tmpObj.Enabled = False
                ElseIf (TypeName(tmpObj) = "DataGrid") Then
                    If tmpObj.Tag <> "." Then
                        tmpObj.Enabled = False
                    End If
                ElseIf (TypeName(tmpObj) = "ComboBox") Then
                    tmpObj.Enabled = False
                ElseIf (TypeName(tmpObj) = "oTab") Then
                    tmpObj.ActiveTab = 0
                    tmpObj.TabEnabled(1) = True
                End If
            Next
    End Select
End Sub

Public Sub ClearDataValue(tmpForm As Object)
    Dim tmpObj As Object
    For Each tmpObj In tmpForm
        If (TypeName(tmpObj) = "oTextBox" And tmpObj.Tag <> ".") Then
            tmpObj.Text = ""
        ElseIf (TypeName(tmpObj) = "oDateBox") Then
            tmpObj.Text = "__/__/____"
        ElseIf TypeName(tmpObj) = "oCheckBox" Then
            tmpObj.Value = Unchecked
        ElseIf TypeName(tmpObj) = "ComboBox" Then
            tmpObj.ListIndex = 0
        ElseIf (TypeName(tmpObj) = "DataGrid") Then
            tmpObj.Refresh
        End If
    Next
End Sub

Public Function GetSearchString(tmpForm As Object) As String
    Dim tmpObj As Object
    Dim sWhere As String
    For Each tmpObj In tmpForm
        If (TypeName(tmpObj) = "oTextBox" And tmpObj.Tag <> ".") Then
            If tmpObj.Text <> "" And tmpObj.Mandatory = True Then
                sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & Mid$(tmpObj.Name, 4, Len(tmpObj.Name)) & " LIKE '" & Trim$(tmpObj.Text) & "%'"
            End If
        ElseIf (TypeName(tmpObj) = "oDateBox") Then
            If tmpObj.Text <> "__/__/____" Then
                sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & Mid$(tmpObj.Name, 4, Len(tmpObj.Name)) & " LIKE '" & Trim$(tmpObj.Text) & "%'"
            End If
        End If
    Next
    GetSearchString = Trim$(sWhere)
End Function

Public Function MandatoryOK(tmpForm As Object) As Boolean
    Dim tmpObj As Object
    For Each tmpObj In tmpForm
        If (TypeName(tmpObj) = "oTextBox" And tmpObj.Tag <> ".") Then
            If tmpObj.Mandatory = True Then
                If tmpObj.Text = "" Then
                    MsgBox "Field '" & tmpObj.Label & "' is mandatory. Null value is not allowed.", vbInformation, ProjectVersion
                    Exit Function
                End If
            End If
        End If
    Next
    MandatoryOK = True
End Function

Public Sub GetAccessLevel(tbMain As Object, sRole As String, sForm As String, BitArr() As Boolean)
    On Error GoTo ErrHandler
    Dim tmpCN  As New Connection
    tmpCN.CursorLocation = adUseClient
    tmpCN.ConnectionString = sConnString_
    tmpCN.Open
    
    Dim tmpRS As New Recordset
    If tmpRS.State = 1 Then tmpRS.Close
    tmpRS.Open "se_GetAccessLevel '" & sRole & "','" & sForm & "'", tmpCN, adOpenStatic, adLockReadOnly
    If tmpRS.RecordCount <> 0 Then
        BitSetEnable tbMain, tmpRS!cAccess, BitArr()
    End If
    
    tmpRS.Close
    tmpCN.Close
    Set tmpRS = Nothing
    Set tmpCN = Nothing
    
ErrHandler:
    If Err.Number <> 0 Then
        MsgBox Err.Description, vbCritical, ProjectVersion
    End If
End Sub

Public Sub BitSetEnable(sTB As Object, sValue As String, BitArr() As Boolean)
    Dim i As Integer
    Dim j As Integer
    ReDim BitArr(1 To 19) As Boolean

    If sValue = "F" Then
        For i = 1 To 19
            BitArr(i) = True
        Next i
    Else
        For i = 1 To 19
            BitArr(i) = IIf(Mid$(sValue, i, 1) = "1", True, False)
        Next i
   End If
End Sub

Public Sub BitEnable(BitArr() As Boolean, tmpForm As Object, tmpMDI As Object)
    Dim i As Integer
    For i = 1 To tmpMDI.tbMain.Buttons.Count
        tmpMDI.tbMain.Buttons.Item(i).Enabled = False
    Next i
            
    Select Case tmpForm.Mode
        Case AddEditNew
            tmpMDI.tbMain.Buttons.Item(5).Enabled = BitArr(4)
            tmpMDI.tbMain.Buttons.Item(6).Enabled = BitArr(5)
            tmpMDI.tbMain.Buttons.Item(18).Enabled = BitArr(13)
            tmpMDI.tbMain.Buttons.Item(19).Enabled = BitArr(14)
            tmpMDI.tbMain.Buttons.Item(25).Enabled = BitArr(18)
            tmpMDI.tbMain.Buttons.Item(26).Enabled = BitArr(19)
        Case Find
            tmpMDI.tbMain.Buttons.Item(1).Enabled = BitArr(1)
            'tmpMDI.tbMain.Buttons.Item(2).Enabled = BitArr(2)
            'tmpMDI.tbMain.Buttons.Item(3).Enabled = BitArr(3)
            tmpMDI.tbMain.Buttons.Item(8).Enabled = BitArr(6)
            tmpMDI.tbMain.Buttons.Item(11).Enabled = BitArr(8)
            tmpMDI.tbMain.Buttons.Item(25).Enabled = BitArr(18)
            tmpMDI.tbMain.Buttons.Item(26).Enabled = BitArr(19)
        Case Normal
            tmpMDI.tbMain.Buttons.Item(1).Enabled = BitArr(1)
            tmpMDI.tbMain.Buttons.Item(2).Enabled = BitArr(2)
            tmpMDI.tbMain.Buttons.Item(3).Enabled = BitArr(3)
            tmpMDI.tbMain.Buttons.Item(8).Enabled = BitArr(6)
            tmpMDI.tbMain.Buttons.Item(9).Enabled = BitArr(7)
            tmpMDI.tbMain.Buttons.Item(11).Enabled = BitArr(8)
            tmpMDI.tbMain.Buttons.Item(12).Enabled = BitArr(9)
            tmpMDI.tbMain.Buttons.Item(13).Enabled = BitArr(10)
            tmpMDI.tbMain.Buttons.Item(14).Enabled = BitArr(11)
            tmpMDI.tbMain.Buttons.Item(15).Enabled = BitArr(12)
            tmpMDI.tbMain.Buttons.Item(16).Enabled = BitArr(13)
            tmpMDI.tbMain.Buttons.Item(21).Enabled = BitArr(15)
            tmpMDI.tbMain.Buttons.Item(22).Enabled = BitArr(16)
            tmpMDI.tbMain.Buttons.Item(23).Enabled = BitArr(17)
            tmpMDI.tbMain.Buttons.Item(25).Enabled = BitArr(18)
            tmpMDI.tbMain.Buttons.Item(26).Enabled = BitArr(19)
    End Select
End Sub
